package org.xin.framework.service.impl;


import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.xin.framework.base.service.impl.IBaseServiceImpl;
import org.xin.framework.constant.DataStatus;
import org.xin.framework.mapper.SysDictionaryItemMapper;
import org.xin.framework.pojo.entity.SysDictionary;
import org.xin.framework.pojo.entity.SysDictionaryItem;
import org.xin.framework.service.ISysDictionaryItemService;

import java.util.List;

/**
* <p>
    * 系统模块-字典条目表 服务实现类
    * </p>
*
* @author: xin
* @date: Create in 2021-10-09
*/
@Slf4j
@Service
public class SysDictionaryItemServiceImpl extends IBaseServiceImpl<SysDictionaryItem, SysDictionaryItemMapper> implements ISysDictionaryItemService {
    @Override
    public List<SysDictionaryItem> selectByDictionaryId(String sysDictionaryId) {
        lambdaQueryWrapper()
                .eq(SysDictionaryItem::getSysDictionaryId, sysDictionaryId)
                .eq(SysDictionaryItem::getDictionaryItemStatus, DataStatus.ENABLE.ordinal());
        return baseMapper.selectList(lambdaQueryWrapper);
    }

    @Override
    public SysDictionaryItem selectNameByDictionaryIdAndCode(String sysDictionaryId, String code) {
        lambdaQueryWrapper()
                .eq(SysDictionaryItem::getSysDictionaryId, sysDictionaryId)
                .eq(SysDictionaryItem::getCode, code)
                .eq(SysDictionaryItem::getDictionaryItemStatus, DataStatus.ENABLE.ordinal());
        return baseMapper.selectOne(lambdaQueryWrapper);
    }
}
